﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Dycox.Linq
{
    public struct Int32Range : IRange
    {
        int? _lower, _upper;

        public Int32Range(int lower, int upper)
        {
            _lower = lower;
            _upper = upper;
        }

        public int Lower
        {
            get { return _lower.GetValueOrDefault(int.MinValue); }
            set
            {
                _lower = value;
            }
        }

        public int Upper
        {
            get { return _upper.GetValueOrDefault(int.MaxValue); }
            set { _upper = value; }
        }

        public bool IsEmpty
        {
            get { return !_lower.HasValue && !_upper.HasValue; }
        }

        object IRange.LowerBound
        {
            get { return _lower; }
        }

        bool IRange.IsLowerSpecified
        {
            get { return _lower.HasValue; }
        }

        object IRange.UpperBound
        {
            get { return _upper; }
        }

        bool IRange.IsUpperSpecified
        {
            get { return _upper.HasValue; }
        }
    }
}
